<?php

require_once dirname(__FILE__) . '/../lib/dictamenGeneratorConfiguration.class.php';
require_once dirname(__FILE__) . '/../lib/dictamenGeneratorHelper.class.php';

/**
 * dictamen actions.
 *
 * @package    reclamos
 * @subpackage dictamen
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 12474 2008-10-31 10:41:27Z fabien $
 */
class dictamenActions extends autoDictamenActions
{

  public function executeNew(sfWebRequest $request)
  {
    parent::executeNew($request);
    $this->form->setDefault('reclamo_id', $request->getParameter('id'));

  }

  public function executeIndex(sfWebRequest $request)
  {
    parent::executeIndex($request);
    $c = new Criteria();
    $c->add(DictamenPeer::RECLAMO_ID,$request->getParameter('id'));
    $this->pager->setCriteria($c);
    $this->pager->init();


  }

  protected function processForm(sfWebRequest $request, sfForm $form)
  {
    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
    if ($form->isValid())
    {
      $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';

      $dictamen = $form->save();

      $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $dictamen)));
      $this->getUser()->setFlash('notice', $notice);
      $this->redirect(array('sf_route' => 'dictamen_edit', 'sf_subject' => $dictamen));
    }
    else
    {
      $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
    }

  }

  public function executeVolver(sfWebRequest $request)
  {
    $this->redirect('@reclamo');

  }

}
